var permissions = $('#filter_permission_ids');
permissions.html("<%= escape_javascript(options_for_select(@permissions.map {|p| [p.name, p.id] })) %>");
permissions.multiSelect('refresh');
var url = '<%= escape_javascript(@search_path) %>'
var controller = $('#filter_resource_type').val();
var autocompleteID = $('.search-input').data('autocompleteId');
tfm.autocomplete.updateController( controller, url, autocompleteID);
<% if @granular %>
  $('#granular_warning').hide();
  $('#granular_form').show();
<% else %>
  $('#granular_warning').show();
  $('#granular_form').hide();
  $('#filter_unlimited').prop('checked', true);
<% end %>

<% if @show_organizations %>
  $('li a[href="#organizations"]').toggle($('#override_taxonomy_checkbox').prop('checked'));
<% else %>
  $('li a[href="#organizations"]').hide();
<% end %>
$('#filter_resource_type').attr('data-allow-organizations', <%= !!@show_organizations %>);

<% if @show_locations %>
  $('li a[href="#locations"]').toggle($('#override_taxonomy_checkbox').prop('checked'));
<% else %>
  $('li a[href="#locations"]').hide();
<% end %>
$('#filter_resource_type').attr('data-allow-locations', <%= !!@show_locations %>);

<% if @show_organizations || @show_locations %>
  $('#override_taxonomy_form').show();
$('#override_taxonomy_checkbox').prop('disabled', false);
<% else %>
  $('#override_taxonomy_form').hide();
  $('#override_taxonomy_checkbox').prop('disabled', true);
<% end %>
